<?php
/**************************************************************************
	ESAM (EVE to SMF API Module)
	Copyright (C) 2009  Sasha J

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/


function template_main() {
    global $context, $txt;
    echo '<table cellspacing="0" cellpadding="5" border="0" width="100%" class="tborder">
			<tbody><tr class="titlebg">
				<td>'.$txt['eve_general_settings'].'</td>
			</tr><tr>
				<td class="windowbg2">';
    if($context['extra_text']) {
        echo '<p><strong>'.$context['extra_text'].'</strong></p>';
    }
    echo '<form action="', $scripturl, '?action=evesettings;sa=index" method="post" accept-charset="', $context['character_set'], '">';
    echo '<input type="checkbox" name="need_to_enter" id="need_to_enter"';
    if(getEveSetting('GLOBAL_REQUIRED_API') == 0) {
        echo 'checked="checked"';
    }
    echo ' /> ';
    echo '<label for="need_to_enter">'.$txt['eve_must_use_api'].'</label><br />';
    echo '<br /><input type="submit" name="submit" value="'.$txt['eve_submit'].'"/></form>';
   	echo '</td></tr</tbody></table>';
}
function template_eveabout() {
    global $context, $txt;
    echo '<table cellspacing="0" cellpadding="5" border="0" width="100%" class="tborder">
			<tbody><tr class="titlebg">
				<td>'.$txt['eve_about'].'</td>
			</tr><tr>
				<td class="windowbg2">';
    echo '<p><strong>ESAM (EVE to SMF API Module) v'.getEveModVersion().' by Sasha J</strong></p>';
   	echo '</td></tr</tbody></table>';
}
function template_rules() {
    global $context, $txt;
    echo '<p><strong style="color: red;">'.$context['extra_text'].'</strong></p>';
    echo '<table cellspacing="0" cellpadding="5" border="0" width="100%" class="tborder">
			<tbody><tr class="titlebg">
				<td>'.$txt['eve_current_rules'].'</td>
			</tr><tr>
				<td class="windowbg2">';
    if(count($context['everules']) == 0) {
        echo '<strong>'.$txt['eve_no_rules'].'</strong>';
    } else {
        echo '<ul>';
        foreach($context['everules'] as $key => $val) {
            echo '<li>' . $txt['eve_if']. ' <strong>';
            if($val['EVE_ROLE'] == '') echo $txt['eve_member'];
            else echo $txt['eve_director'];
            echo '</strong>';
            if($val['EVE_CORP_ID'] != null) {
                echo ' '.$txt['eve_corporation'];
                echo ' <strong>'.getCorporationName($val['EVE_CORP_ID']).'</strong>';
            } else {
                echo ' '.$txt['eve_any_corp_in'];
                echo ' <strong>'.getAllianceName($val['EVE_ALLIANCE_ID']).'</strong> '.$txt['eve_alliance'];
            }
            echo ' '.$txt['eve_after_registartion_group'].' ';
            echo '<strong>'.getGroupName($val['ID_GROUP']).'</strong> ';
            echo '[<a href="' . $scripturl . '?action=evesettings;sa=remove_rule;id=' . $val['ID_RULE'] . '">';
            echo $txt['eve_remove'] . '</a>]</li>';
        }
        echo '</ul>';
    }
   	echo '</td></tr</tbody></table>';
    // add rule
    echo '<br /><table cellspacing="0" cellpadding="5" border="0" width="100%" class="tborder">
			<tbody><tr class="titlebg">
				<td>'.$txt['eve_add_rule'].'</td>
			</tr><tr>
				<td class="windowbg2">';
    echo '<form action="', $scripturl, '?action=evesettings;sa=rules" method="post" accept-charset="', $context['character_set'], '">';
    echo '<label for="group">'.$txt['eve_add_group'].'</label> ';
    echo '<select id="group" name="group">';
    foreach($context['groups'] as $key => $val) {
        echo '<option value="' . $val['ID_GROUP'] . '">' . $val['groupName'] . '</option>';
    }
    echo '</select><br />'.$txt['eve_if']. ' ';
    echo '<select id="role" name="role">';
    echo '<option value="">'.$txt['eve_member'].'</option>';
    echo '<option value="roleDirector">'.$txt['eve_director'].'</option>';
    echo '</select><br />';
    echo '<input type="radio" name="selection" value="alliance" checked="checked" /> ';
    echo '<label for="alliances">'.$txt['eve_alliance'].':</label> ';
    echo '<select id="alliances" name="alliances">';
    foreach($context['alliances'] as $key => $val) {
        echo '<option value="' . $val['EVE_ID'] . '">' . $val['EVE_NAME'] . '</option>';
    }
    echo '</select><br />';
    echo '<input type="radio" name="selection" value="corporation" /> ';
    echo '<label for="corp">'.$txt['eve_corporation'].':</label> ';
    echo '<select id="corp" name="corp">';
    foreach($context['corp'] as $key => $val) {
        echo '<option value="' . $val['EVE_ID'] . '">' . $val['EVE_NAME'] . '</option>';
    }
    echo '</select><br />';
    echo '<input type="submit" value="'.$txt['eve_submit'].'"/></form>';
    //echo '<pre>'; print_r($_REQUEST); echo '</pre>';
    echo '</td></tr</tbody></table>';
}

function template_corp() {
    global $context, $txt;
    echo '<table cellspacing="0" cellpadding="5" border="0" width="100%" class="tborder">
			<tbody><tr class="titlebg">
				<td>'.$txt['eve_current_corporations'].'</td>
			</tr><tr>
				<td class="windowbg2">';
    echo '<p><strong style="color: red;">'.$context['extra_text'].'</strong></p><p>';
    foreach($context['corp'] as $key => $val) {
        echo $val['EVE_NAME'] . ' ('.$txt['eve_alliance'].': ' . getAllianceName($val['EVE_ALLIANCE_ID']) .
        ') <a href="' . $scripturl . '?action=evesettings;sa=remove_corp;id=' . $val['EVE_ID'] . '">'.
        $txt['eve_remove'] . '</a><br />';
    }
    echo '</a></p>';
   	echo '</td></tr</tbody></table>';

    echo '<br /><table cellspacing="0" cellpadding="5" border="0" width="100%" class="tborder">
			<tbody><tr class="titlebg">
				<td>'.$txt['eve_add_corps_from_alliance'].'</td>
			</tr><tr>
				<td class="windowbg2">';
    echo '<form action="', $scripturl, '?action=evesettings;sa=add_corps" method="post" accept-charset="', $context['character_set'], '">';
    echo '<label for="alliance">'.$txt['eve_add_corps_from_alliance'].':</label><br />';
    echo '<select id="alliances" name="alliances">';
    foreach($context['alliances'] as $key => $val) {
        echo '<option value="' . $val['EVE_ID'] . '">' . $val['EVE_NAME'] . '</option>';
    }
    echo '</select><br /><input type="submit" value="'.$txt['eve_submit'].'"/></form>';
    echo '</td></tr</tbody></table>';
}

function template_alliances() {
    global $context, $txt;
    echo '<table cellspacing="0" cellpadding="5" border="0" width="100%" class="tborder">
			<tbody><tr class="titlebg">
				<td>'.$txt['eve_load_alliance_data'].'</td>
			</tr><tr>
				<td class="windowbg2">';
    echo '<strong>' . $txt['eve_alliance_data_reloaded'] . '</strong><br /><p>';
    foreach($context['alliances'] as $key => $val) {
        echo $val['EVE_NAME'] . '<br />';
    }
    echo '</p>';
	echo '</td></tr</tbody></table>';
}

?>
